package com.bawei.lib_base.utils.utils.utils

import com.blankj.utilcode.util.SPUtils
import com.zyj.retrofit.adapter.FlowCallAdapterFactory
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object RetrofitUtils{
    val okHttpClient by lazy {
        OkHttpClient.Builder()
            .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
            .addInterceptor {
                val builder = it.request().newBuilder()
                    .addHeader("accessId","4f2af052aea24979bc33565770bc1c06")
                    .addHeader("token",SPUtils.getInstance().getString(Cons.TOKEN))
                    .build()
                it.proceed(builder)
            }
            .build()
    }

    val parkRetrofit by lazy {
        Retrofit.Builder()
            .client(okHttpClient)
            .baseUrl(Cons.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(FlowCallAdapterFactory.create())
            .build()
    }
}